package cn.piesat.scanning.service.impl;

import cn.piesat.scanning.dao.HtPathConfigurationDAO;
import cn.piesat.scanning.dto.HtPathConfigurationDTO;
import cn.piesat.scanning.service.HtPathConfigurationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * 路径信息的服务层接口实现
 */
@Service("htPathConfigurationService")
public class HtPathConfigurationServiceImpl implements HtPathConfigurationService {

    @Autowired
    private HtPathConfigurationDAO htPathConfigurationDAO;

    /**
     * 根据路径ID查询路径详细信息
     * @param id
     * @return
     */
    @Override
    public HtPathConfigurationDTO findById(String id) {
        Optional<HtPathConfigurationDTO> byId = htPathConfigurationDAO.findById(id);
        HtPathConfigurationDTO dto = byId.get();
        return dto;
    }

    @Override
    public List<HtPathConfigurationDTO> findByIdList(List<String> pathIdList) {
        if (pathIdList.isEmpty()) {
            return new ArrayList<>();
        }
        return htPathConfigurationDAO.findAllById(pathIdList);
    }
}
